import { getDropdownData } from '@/api/common'

const selectList = {
    state: {
        selectList: {}
    },

    mutations: {
        SET_SELECTLIST: (state, data) => {
            state.selectList = data
        }
    },

    actions: {
        // 获取下拉框数据
        getSelectList({ commit, state }) {
            return new Promise((resolve, reject) => {
                const data = {}
                getDropdownData({}).then(response => {
                    for (const i in response.data) {
                        data[i] = response.data[i]
                    }
                    commit('SET_SELECTLIST', data)
                    resolve(data)
                }).catch((err) => {
                    reject(err)
                })
            })
        }
    }
}

export default selectList
